<?php
if(!isset($_SESSION['username'])){
	redirect(HOME);
}
if($_SESSION['level']==1 || $_SESSION['level']==2){
}else{
redirect(HOME);
}
if(isset($_GET['ac'])){
	$id=intval($_GET['id']);
	$id2=intval($_GET['id2']);
	if($_GET['ac']=='del'){
		$dbcon=new db;
		$dbcon->connect();
		$dbcon->query("delete from comment where id=".$id);
		$dbcon->close();
		$cache2=new cache;
		$cache2->flush("comment_".$_GET['url'].$id2);
	}
	if($_GET['ac']=='pass'){
		$dbcon=new db;
		$dbcon->connect();
		$dbcon->query("update  comment set status=0 where id=".$id);
		$dbcon->close();
		$cache2=new cache;
		$cache2->flush("comment_".$_GET['url'].$id2);
	}

	exit();
}


 $dbcon=new db;
 $dbcon->connect();
 $dbcon->query("select * from comment where status=1 order by id desc");
 $report[num]=$dbcon->num_rows();
 if($dbcon->num_rows()>0){
 	while($row=$dbcon->fetch()){
	$report[data][]=$row;
	}
 }
$data=$report;
	$data1['title']="Kiểm Duyệt Comment";
		//---Load View--------------------
	loadview('template/header',$data1);
	loadview("comment/checkcomment",$data);
	loadview("template/right");
	
